package com.dragoncombin.homework.Module03;


public class Problem01 {

    /*
        编程题：编程统计字符串"ABCD123!@#$%ab" 中大写字母、小写字母、数字、其他字符的个数并打印出来
    */
    public static void main(String[] args) {

        String str = "ABCD123!@#$%ab";
        int[] arr = new int[4];
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (c >= 'A' && c <= 'Z') {
                arr[0] += 1;
            } else if (c >= 'a' && c <= 'z') {
                arr[1] += 1;
            } else if (c >= '0' && c <= '9') {
                arr[2] += 1;
            } else {
                arr[3] += 1;
            }
        }
        System.out.println("大写字母: " + arr[0] + "个");
        System.out.println("小写字母: " + arr[1] + "个");
        System.out.println("数字字母: " + arr[2] + "个");
        System.out.println("其他字母: " + arr[3] + "个");

    }
}
